<template>
	<view class="my">
		<!-- 头部卡片 -->
		<template >
			<view  class="my_card"@click="jumpEdit(user, user.id)" v-show="!arruser">
				<view class="info">
					<img class="info_img" :src="user.head_img" alt />
					<view class="info_name">{{ user.name }}</view>
					<view class="info_right">
						<view class="info_text">{{ user.type }}</view>
					</view>
					<span>{{ user.tel }}</span>
				</view>
			</view>
			<view class="my_card" v-show="arruser">
				<view class="info">
					<img class="info_img" src="/static/img/img_avatar.png" alt />
					<view class="info_name">游客123</view>
					<span>快来登入吧~</span>
				</view>
			</view>
		</template>
		<!-- 菜单 -->
		<view class="menu">
			<view class="menu_box">
				<view class="menu_top">
					<view class="left">
						<p>兑换商品</p>
					</view>
					<view class="right">
						<span>{{ menu.text }}</span>
					</view>
				</view>
				<view class="menu_bottom">
					<view class="menu_part" v-for="(item,index) in menu.info" :key="index"
						@click="$navigateTo(item.url)">
						<img :src="item.img" alt />
						<p>{{ item.text }}</p>
					</view>
				</view>
			</view>
		</view>
		<!-- 赚积分 -->
		<view class="integral">
			<view class="integral_box">
				<view class="text">
					<view class="num">{{ integral }}</view>
					<view class="words">当前积分</view>
				</view>
				<view class="button" @click="$navigateTo(info1_url)">
					<span >赚积分</span>
				</view>
			</view>
		</view>
		<!-- 底部单元格 -->
		<view class="cell_group">
			<view class="cell_group_box">
				<view class="cell" v-for="(item, index ) in cell_group" :key="index" @click="$navigateTo(item.url)">
					<img :src="item.img" alt />
					<p>{{ item.text }}</p>
				</view>
				<view class="quit" @click="$navigateTo(login_url)">退出登录</view>
			</view>
		</view>
		<buttom-tabbar></buttom-tabbar>
	</view>
</template>
<script>
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		components: {},
		data() {
			return {
				info1_url: "/pages/user/score/earn/index",
				info_url: "/pages/user/info/edit/index",
				login_url: "/pages/login/index", // 登录页跳转路由
				// 赚积分
				integral_url: '/pages/score/task/index',
				integral: 99999,
				arruser: {},
			};
		},
		watch: {},
		computed: {
			...mapState({
				menu: state => state.user.menu,
				cell_group: state => state.user.cell_group,
				user: state => state.init.user,
				userinfo: state => state.init.userinfo,
			}),
		},
		methods: {
			jumpEdit(user, id) {
				this.$store.dispatch('init/get_user', user)
				uni.navigateTo({
					url: this.info_url + '?user.id=' + id,
				})
			}
		},
		beforeCreate() {},
		created() {},
		beforeMount() {},
		mounted() {
			this.arruser = (JSON.stringify(this.user) == "{}")
			},
		beforeUpdate() {},
		updated() {},
		beforeDestroy() {},
		destroyed() {},
	};
</script>
<style scoped lang='scss'>
	@import "./index.scss";
</style>
<style>
	page {
		padding-bottom: 0;
	}
</style>
